package o2o.web.actions.sys;

import com.jinyou.utils.common.AjaxResult;
import o2o.dao.PO.sys.SysConfigXcxPush;
import o2o.service.sys.SysConfigXcxPushService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.sql.SQLException;
import java.util.List;

/**
 * @author qilonghe【1061268464@qq.com】
 * @ClassName AppletPush
 * @Description:
 * @date 2020/11/2 0002 上午 8:59
 * @Version 1.0
 */
@RestController
public class SysConfigXcxPushController {
    @Autowired
    SysConfigXcxPushService sysConfigXcxPushService;

    // 查询小程序推送相关配置信息
    @RequestMapping(method = RequestMethod.POST, value = "base/xcxPush/list")
    public String list(String appFlag) {
        List<SysConfigXcxPush> list = sysConfigXcxPushService.list(appFlag);
        return AjaxResult.successResult(list);
    }

    // 更新配置信息
    @RequestMapping(method = RequestMethod.POST, value = "base/xcxPush/modify")
    public String modify(SysConfigXcxPush sysConfigXcxPush) {
        try {
            sysConfigXcxPushService.modify(sysConfigXcxPush);
            return AjaxResult.successResult();
        } catch (SQLException e) {
            e.printStackTrace();
            return AjaxResult.errorResult("更新失败,请稍后重试");
        }
    }
}